package com.inventory.service;

import com.inventory.entity.Inventory;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public interface InventoryService {
    boolean doDeleteInventoryInfo(Integer inventory);

    Inventory doGetInventoryInfo(Inventory inventory);

    // 正常业务方法
    List<Inventory> doGetInventoryInfoList();
    boolean doAddInventory(Inventory inventory);

    boolean doAddInventoryInfo(Inventory inventory);

    boolean doModifyInventoryInfo(Inventory inventory);
    boolean doDeleteInventory(Integer iid);

    // 熔断降级方法（添加详细日志）
    default List<Inventory> listFallback(Throwable ex) {
        // 记录详细日志
        System.err.println("获取库存列表熔断触发: " + ex.getMessage());
        return Collections.emptyList();
    }

    default boolean addFallback(Inventory inventory, Throwable ex) {
        System.err.println("添加库存熔断触发: " + ex.getMessage());
        return false;
    }

    default boolean modifyFallback(Inventory inventory, Throwable ex) {
        System.err.println("修改库存熔断触发: " + ex.getMessage());
        return false;
    }

    default boolean deleteFallback(Integer iid, Throwable ex) {
        System.err.println("删除库存熔断触发: " + ex.getMessage());
        return false;
    }

    List<Inventory> doQueryInventoryInfoList(Inventory inventory);
}